# 写文件
f1 = open("data/newfile.txt", mode="w", encoding="utf8")

f2 = open("data/students.txt", mode="r", encoding="utf8")

# 写一个文件，如果换行，得手动加上 "\n"
f1.writelines(f2.readlines())

f1.close()
f2.close()

# with open
# 采用这种方式，不需要手动close()
with open("data/students.txt", mode="r", encoding="utf8") as f3:
    with open("data/newfile2.txt", mode="w", encoding="utf8") as f4:
        f4.writelines(f3.readlines())
